package com.edu.web.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.edu.entity.User;
import com.edu.entity.shopDingdong;
import com.edu.service.UserBackgroundService;
import com.edu.service.impl.UserBackgroundServiceImpl;

/**
 * Servlet implementation class updateShopServlet
 */
@WebServlet("/updateShopServlet")
public class updateShopServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public updateShopServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		request.setCharacterEncoding("UTF-8");
		String shopId = request.getParameter("shopId");
		String shopName = request.getParameter("shopName");
		String shopUrl = request.getParameter("shopUrl");
		String shopPrice = request.getParameter("shopPrice");
		String shopType = request.getParameter("shopType");
		System.out.println("这是修改id"+shopId);
		int sId = Integer.parseInt(shopId);
		double sprice = Double.parseDouble(shopPrice);
		
		shopDingdong shop=new shopDingdong(sId, shopUrl, shopName, sprice,shopType);
		UserBackgroundService userBackService = new UserBackgroundServiceImpl();
		userBackService.updateShopById(shop);
		response.sendRedirect("selectByShopServlet");

	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
